<include file='Common:header' />
<link rel="stylesheet" type="text/css" media="all" href="__PUBLIC__/sldate/daterangepicker-bs3.css" />
<script type="text/javascript" src="__PUBLIC__/sldate/moment.js"></script>
<script type="text/javascript" src="__PUBLIC__/sldate/daterangepicker.js"></script>
<script src="__PUBLIC__/My97DatePicker/WdatePicker.js"></script>
<!-- /section:basics/navbar.layout -->
<div class="main-container" id="main-container">

    <!-- #section:basics/sidebar -->

    <include file='Common:left' />
    <!-- /section:basics/sidebar -->
    <div class="main-content">
        <div class="main-content-inner">
            <div class="page-content">



                <div class="row maintop">
                    <form name="admin_list_sea" class="form-search" method="get" action="__URL__/table_list">
                    <div class="col-xs-4 col-sm-2">

                            <div class="input-group">
                                <input type="text" name="y"   class="form-control search-query admin_sea" value="{$year}" placeholder="输入查询年份" />
                            </div>

                    </div>
                        <div class="col-xs-4 col-sm-2">

                            <div class="input-group">
                                <input type="text" name="com"   class="form-control search-query admin_sea" value="{$company}" placeholder="输入查询公司名" />
                            </div>

                        </div>
                        <div class="col-xs-4 col-sm-2">

                            <div class="input-group">
                                <input type="text" name="q"   class="form-control search-query admin_sea" value="{$quarter}" placeholder="输入查询季度" />
                            </div>

                        </div>
                        <div class="col-xs-4 col-sm-2">

                            <select name="status" class="form-control search-query admin_sea">
                                <option value="">选择报表状态</option>
                                <option value="0" <if condition="$table_state eq 0">selected=selected</if>>未填写</option>
                                <option value="1" <if condition="$table_state eq 1">selected=selected</if>>待审核</option>
                                <option value="2" <if condition="$table_state eq 2">selected=selected</if>>未通过</option>
                                <option value="3" <if condition="$table_state eq 3">selected=selected</if>>已完成</option>
                                <option value="4" <if condition="$table_state eq 4">selected=selected</if>>已过期</option>
                            </select>

                        </div>
                        <div class="col-xs-4 col-sm-3">

                            <div class="input-group">
                                        <span class="input-group-addon">
											<i class="ace-icon fa fa-check"></i>
										</span>
                                <select name="t" class="form-control search-query admin_sea">
                                    <option value="">选择报表</option>
                                    <volist name="tableid" id="v">
                                        <option value="{$v.id}" <if condition="$tid eq $v['id']">selected=selected</if> >{$v.title}</option>
                                    </volist>
                                </select>
                                <span class="input-group-btn">
											<button type="submit" class="btn btn-xs  btn-purple">
												<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
												搜索
											</button>
										</span>
                            </div>

                        </div>
                    </form>
                    <div class="input-group-btn">
                        <a href="__URL__/table_list">
                            <button type="button" class="btn btn-xs  btn-purple">
                                <span class="ace-icon fa fa-globe icon-on-right bigger-110"></span>
                                显示全部
                            </button>
                        </a>
                    </div>


                </div>



                <div class="row">
                    <div class="col-xs-12">
                        <div>
                            <form id="leftnav" name="leftnav" method="post" action="" >
                                <input type="hidden" name="checkk" id="checkk" value="1" /><!--用于判断操作类型-->
                                <table width="100%" class="table table-striped table-bordered table-hover" id="dynamic-table">
                                    <thead>
                                    <tr>
                                        <th width="8%">id</th>
                                        <th width="20%">所属企业</th>
                                        <th width="18%">报表名称</th>
                                        <th width="11%">报表编号</th>
                                        <th width="9%">年份</th>
                                        <th width="8%">季度</th>
                                        <th width="8%">是否填写</th>
                                        <th width="9%">状态</th>
                                        <th width="11%" style="border-right:#CCC solid 1px;">操作</th>
                                    </tr>
                                    </thead>

                                    <tbody>

                                    <foreach name="res" item="v">
                                        <tr>
                                            <td height="28" >{$v.id}</td>
                                            <td>{$v.u_name}</td>
                                            <td>{$v.title}</td>
                                            <td>{$v.code}</td>
                                            <td>{$v.year}</td>
                                            <td>{$v.quarter}</td>
                                            <td><if condition="$v['is_write'] eq 0">未填写<else />已填写</if></td>
                                            <td>
                                                <if condition="($v['is_write'] eq 0) AND ($nowtime gt $v['endtime'])">
                                                    <span style="color: red;">已过期</span>
                                                    <elseif condition="$v['state'] eq 0"/>
                                                    未填写
                                                    <elseif condition="$v['state'] eq 1"/>
                                                    待审核
                                                    <elseif condition="$v['state'] eq 2"/>
                                                    未通过
                                                    <elseif condition="$v['state'] eq 3"/>
                                                    已完成

                                                </if>
                                            </td>
                                            <td>
                                                <div class="hidden-sm hidden-xs action-buttons">
                                                    <if condition="$v['is_write'] eq 1">
                                                        <a   class="btn-success" href="{:U('table_edit',array('id'=>$v['id']))}" title="线上修改">
                                                            <i class="ace-icon fa fa-pencil bigger-100">报表修改</i></a>
                                                    </if>


                                                    <a style="margin-top: 3px; " class="btn-danger" href="javascript:;" onclick="return del({$v['id']});" title="删除">
                                                        <i class="ace-icon fa fa-trash-o bigger-100">删除报表</i></a>
                                                    <if condition="($v['is_write'] eq 0) AND ($nowtime gt $v['endtime'])">
                                                        <a style="margin-top: 3px; " class="blue" href="javascript:;" onclick="return resettime({$v['id']})" title="重置有效期">
                                                            <i class="ace-icon fa fa-calendar-o bigger-100">重置时间</i></a>
                                                    </if>
                                                   <!-- <a style="margin-top: 3px; " class="btn-success" href="{:U('table_info',array('id'=>$v['id']))}" title="查看初始报表">
                                                        <i class="ace-icon fa fa-search bigger-100">初始报表</i>
                                                    </a>-->
                                                </div>
                                            </td>
                                        </tr>
                                    </foreach>
                                    <tr>
                                        <td height="50" colspan="10" align="left">{$show}</td>
                                    </tr>
                                    </tbody>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>

                <include file='Common:header_nav' />

            </div><!-- /.page-content -->
        </div>
    </div><!-- /.main-content -->
    <!-- 修改自定义菜单模态框（Modal） -->
    <div class="modal fade in" id="myModaledit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-backdrop fade in" id="gbbb" style="height: 100%;"></div>
        <form class="form-horizontal" name="dtt_runedit" id="dtt_runedit" method="post" action="__URL__/time_edit">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" id="gb"  data-dismiss="modal"
                                aria-hidden="true">×
                        </button>
                        <h4 class="modal-title" id="myModalLabel">
                            重置有效期
                        </h4>
                    </div>
                    <div class="modal-body">
                        <div class="row">
                            <div class="col-xs-12">

                                <input type="hidden" name="id" value="" id="edit_id">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label no-padding-right" for="form-field-1"> 报表有效期：  </label>
                                    <div class="col-sm-10">
                                        <!--<input type="text" name="endtime" id="edit_time" placeholder="输入有效期" class="col-xs-10 col-sm-5" />-->
                                        <input type="text" style="display: inline-block;" class="col-xs-9 col-sm-3 Wdate" id="edit_time" name="endtime" onFocus="WdatePicker({lang:'zh-cn',dateFmt:'yyyy-MM-dd HH:mm:ss'})" placeholder="请点击选择有效期" />
                                    </div>
                                </div>
                                <div class="space-4"></div>

                            </div>
                        </div>

                    </div>
                    <div class="modal-footer">
                        <button type="submit" class="btn btn-primary">
                            提交保存
                        </button>
                        <button type="button" class="btn btn-default" id="gbb" >
                            关闭
                        </button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </form>
    </div><!-- /.modal -->

    <script>
        function del(id,p){
            layer.confirm('你确定要删除该报表吗？', {icon: 3}, function(index){
                layer.close(index);
                window.location.href="__URL__/table_del/id/"+id;//重新获取当前页面，删除后返回当前页码
            });
        }

        function resettime(id) {
            $.post('{:U("reset_time")}',
                    {id:id},
                    function(data){
                        if(data.status==1){
                            $(document).ready(function(){
                                $("#myModaledit").show(300);
                                $("#edit_id").val(data.id);
                                $("#edit_time").val(data.endtime);
                            });
                        }else{

                        }
                    });
            return false;
        }
        //修改模态框状态
        $(document).ready(function(){
            $("#myModaledit").hide();
            $("#gb").click(function(){
                $("#myModaledit").hide(200);
            });
            $("#gbb").click(function(){
                $("#myModaledit").hide(200);
            });
            $("#gbbb").click(function(){
                $("#myModaledit").hide(200);
            });
        });

        $(function(){
            $('#dtt_runedit').ajaxForm({
                beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
                success: complete, // 这是提交后的方法
                dataType: 'json'
            });

            function checkForm(){
                if(''== $.trim($('#edit_time').val())){
                    layer.alert('请选择报表有效期时间', {icon: 6}, function(index){
                        layer.close(index);
                        $('#edit_time').focus();
                    });
                    return false;
                }
            }
            function complete(data){
                if(data.status==1){
                    layer.alert(data.info, {icon: 6}, function(index){
                        layer.close(index);
                        window.location.href=data.url;
                    });
                }else{
                    alert(data.info);
                    return false;
                }
            }
        });


    </script>
    <include file='Common:footer' />

</div><!-- /.main-container -->
</body>
</html>
